package com.platform.server.controller;

import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.platform.server.service.LogService;

@Controller
public class LogController {
	
	@Autowired
	private LogService logService;
	
	/**
	 * 查看操作日志
	 */
	@RequestMapping("/selectLogList")
	public Object selectLogList(HttpServletRequest request){
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		List<Map<String, Object>> lists = logService.selectLogList();
		for(int i = 0;i < lists.size();i++){
			lists.get(i).put("create_time", sdf.format(lists.get(i).get("create_time")));
		}
		request.setAttribute("lists",lists);
		request.setAttribute("nums",lists.size());
		return "/ui/log/log_list.jsp";
	}
	
	/**
	 * 删除操作日志
	 */
	@RequestMapping("/deleteLog")
	public Object deleteLog(String id){
		int flag = logService.deleteLog(id);
		return "/selectLogList";
	}
}
